<?php 

// *** Documentation
/*______________________________________________________________________________

  Drupal Theme: abstruct
  Template File: page
  Author: Tom at klenwell@gmail.com
  Last Update: Aug 2007

  SUMMARY
    a basic controllor-patterned template based on garland -- this is not meant
    to be a finished theme in itself, but a starting point for others    
        
  NOTES
    drupal coding conventions not followed to the letter, but hopefully the
    formatting here is clean and intuitive nevertheless
    
    use blocks with classes .tl, .tr, .bl, and .br for rounded corners -- more
    info here: http://phosphorusandlime.blogspot.com/2007/08/css-rounded-corner-fairy.html
    
    for default page variables/template, see: http://drupal.org/node/11812
    
______________________________________________________________________________*/

// CONTENT: HTML Elements

  // panels (basic layout block)
  $_HTML['masthead_panel'] = '';
  $_HTML['core_panel'] = '';
  $_HTML['footer_panel'] = '';

  // regions
  $_HTML['content'] = '';
  $_HTML['metabar'] = '';
  $_HTML['title'] = '';
  $_HTML['navbar'] = '';
  $_HTML['sidebar'] = '';
  $_HTML['page_footer'] = '';

  // masthead panel
  $_HTML['site_title'] = '';
  $_HTML['site_slogan'] = '';
  $_HTML['title_block'] = '';
  $_HTML['logo'] = '';
  $_HTML['primary_links'] = '';
  $_HTML['secondary_links'] = '';
  
  // core panel
  $_HTML['help'] = '';
  $_HTML['messages'] = '';
  $_HTML['search_box'] = '';
  $_HTML['breadcrumb'] = '';
  $_HTML['node_title_block'] = '';
  $_HTML['tabs2'] = '';
  $_HTML['content'] = '';
  
  // footer
  $_HTML['page_footer'] = '';
  
  // miscellaneous
  $_HTML['login_status'] = '';
  $_HTML['mission'] = '';
  $_HTML['feed_icons'] = '';
  
  
// CONTROLLER  

  // primary / secondary links
  if ( isset($primary_links) ) $_HTML['primary_links'] = theme('links', $primary_links, array('class' => 'links primary-links'));
  if ( isset($secondary_links) ) $_HTML['secondary_links'] = theme('links', $secondary_links, array('class' => 'links secondary-links'));
  
  // page title
  $site_name_plain = ( $site_name ) ? check_plain($site_name) : '';
  $site_slogan_plain = ( $site_slogan ) ? check_plain($site_slogan) : '';
  if ( !empty($site_name_plain) ) $_HTML['site_title'] = '<h1><a href="'. check_url($base_path) .'" title="'. $site_name_plain .'">' . $site_name_plain .'</a></h1>';
  if ( !empty($site_name_plain) && !empty($site_slogan_plain) ) $_HTML['site_slogan'] = '<div class="slogan">'. $site_slogan_plain .'</div>';
  if ( !empty($_HTML['site_title']) ) $_HTML['title_block'] = <<<HTML
<div id="title">
{$_HTML['site_title'] }
{$_HTML['site_slogan']}
</div>
HTML;

  // navbar region
  $_HTML['navbar'] = '<div id="navbar">' . $navbar . '</div>';
  
  // core elements
  if ( $sidebar ) $_HTML['sidebar'] = $sidebar;
  if ( $help ) $_HTML['help'] = '<div id="help">'. $help .'</div>';
  if ( $messages ) $_HTML['messages'] = '<div id="messages">'. $messages .'</div>';
  if ( $search_box ) $_HTML['search_box'] = '<div id="search_box" class="block_theme">' . $search_box . '</div>';
  if ( $breadcrumb ) $_HTML['breadcrumb'] = $breadcrumb;
  if ( isset($tabs2) )  $_HTML['tabs2'] = '<span id="tabs2">'. $tabs2 .'</span>';
  if ( !empty($content) ) $_HTML['content'] = <<<HTML
  
<div id="drupal_content">
<div class="tl"></div><div class="tr"></div>
$content
<div class="bl"></div><div class="br"></div>
</div>
HTML;
  
  // node title and tabs
  $ntb_class = ( $tabs ) ? 'with-tabs' : 'without-tabs';
  $ntb_title = ( $title ) ? '<h2 class="'. $ntb_class .'">'. $title .'</h2>' : '';
  $ntb_open = ( $tabs ) ? '<div id="tabs-wrapper" class="clear-block">' : '';
  $ntb_close = ( $tabs ) ? $tabs .'</div>' : '';
  $_HTML['node_title_block'] = "<div id=\"drupal_title\">{$ntb_open}\n{$ntb_title}\n{$ntb_close}</div>";
  
  // footer
  if ( !empty($page_footer) ) $_HTML['page_footer'] = $page_footer;
  
  // miscellaneous
  $_HTML['login_status'] = phptemplate_user_login_status();
  if ( $mission ) $_HTML['mission'] = '<div id="mission">'. $mission .'</div>';
  if ( $feed_icons ) $_HTML['feed_icons'] = '<div id="feed_icons">' . $feed_icons . '</div>';
  $js_src_tableless = base_path() . path_to_theme() . '/javascript/kw.tableless.js';
  
  
// OUTPUT

  // masthead panel
  $_HTML['masthead_panel'] = <<<HTML
  
<!-- MASTHEAD PANEL -->
<!-- #metabar -->
<div id="metabar">
<div class="tl"></div><div class="tr"></div>
<div class="left">{$_HTML['login_status']}</div>
{$_HTML['primary_links']}
<div class="bl"></div><div class="br"></div>
</div>

<!-- #masthead_panel -->
<div id="masthead_panel">
<div id="banner">
{$_HTML['logo']}
{$_HTML['title_block']}
<div class="clear"></div>
</div>
</div>

<!-- #navbar -->
{$_HTML['navbar']}
  
HTML;


  // core panel
  $_HTML['core_panel'] = <<<HTML
  
<!-- CORE PANEL -->
<div id="core_panel">
<div id="core_panel_child">

<!-- #sidebar -->
<div id="sidebar">
<div class="child">

{$_HTML['mission']}
{$_HTML['search_box']}
{$_HTML['sidebar']}

<div class="clear"></div>

</div>
</div>
<!-- end sidebar -->


<!-- #core -->
<div id="core">
<div class="child">

{$_HTML['breadcrumb']}
{$_HTML['node_title_block']}
{$_HTML['tabs2']}
<div class="clear"></div>

{$_HTML['help']}
{$_HTML['messages']}
{$_HTML['content']}

<div class="clear"></div>

</div>
</div>
<!-- end core -->

<div class="clear"></div>

</div>
</div>
<!-- end core_panel -->
  
HTML;

  // footer panel
  $_HTML['footer_panel'] = <<<HTML
  
<!-- footer_panel -->
<div id="footer_panel">

<div id="footer">
<div class="tl"></div><div class="tr"></div>
{$_HTML['feed_icons']}
{$_HTML['page_footer']}
<div class="clear"></div>
<div class="bl"></div><div class="br"></div>
</div>

</div>
  
HTML;


// Begin HTML Output
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language ?>" lang="<?php print $language ?>">
<head>
<title><?php print $head_title ?></title>

<?php print $head ?>
<?php print $styles ?>
<?php print $scripts ?>

<!-- external stylesheets: template, print, ie -->
<style type="text/css" media="print">@import "<?php print base_path() . path_to_theme() ?>/print.css";</style>
<!--[if lt IE 7]>
<style type="text/css" media="all">@import "<?php print base_path() . path_to_theme() ?>/fix-ie.css";</style>
<![endif]--> 

<!-- internal style sheet -->
<style type="text/css">
</style>
<!-- end internal style sheet -->



<!-- external javascript -->
<script type="text/javascript" src="<?php print $js_src_tableless; ?>"></script>

<!-- internal javascript -->
<script type="text/javascript" language="javascript">
js_onload = function() 
{
  // vcenter_dom_in_window('tpl-page');
  balance_doms(['sidebar', 'core']);
}

window.onload=js_onload;
</script>

</head>


<!-- BODY -->  
<body>
<div id="tpl-page" class="page">

<?php print $_HTML['masthead_panel']; ?>
<?php print $_HTML['core_panel']; ?>
<?php print $_HTML['footer_panel']; ?>

</div>

<?php print $closure ?>

</body>
</html>
